﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

using SolrExample.Tests;
using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;
using SolrExample.Common;
using SolrExample.Interface.DomainObject;
using SolrNet.Impl;
using SolrNet.Commands;
using SolrExample.Tests.SolrClient;
using System.Xml.Linq;

namespace SolrExample.CompareFieldName
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestFixture]
    public class CompareTests
    {
        [TestFixtureSetUp]
        public void InitializeAllTests()
        {

        }

        [Test]
        public void Test1()
        {
            string solrPath = @"D:\SolrExample\SolrExample.Tests\CompareFieldName\Solr.xml";
            string postPath = @"D:\SolrExample\SolrExample.Tests\CompareFieldName\Post.xml";

            XElement rootSolr = XElement.Load(solrPath);
            XElement rootPath = XElement.Load(postPath);

            IList<string> listSolr = (from T in rootSolr.Descendants("field")
                                      select T.Attribute("name").Value).ToList();
            IList<string> listPost = (from T in rootPath.Descendants("field")
                                      select T.Attribute("name").Value).ToList();
            
            IList<string> listResult = new List<string>();
            foreach (string s in listPost)
            {
                if (!listSolr.Contains(s))
                    listResult.Add(s);
            }

            foreach (string s in listResult)
            {
                Console.WriteLine(s);
            }
        }

        [TestFixtureTearDown]
        public void CleanupAllTests() { }

    }

}
